game_manager
{
	spawn
	{

		wait 30
		wm_allied_respawntime 20
		wm_axis_respawntime 30
		wm_set_defending_team 0
		wm_set_round_timelimit 12

		wm_setwinner 0

		setstate cp_wobj invisible

		setstate forward_spawn_2 invisible
		setstate axis_teamdoor1_open invisible
		setstate axis_teamdoor2_open invisible

		setstate flak88_1_d invisible
		setstate flak88_2_d invisible
		setstate flak88_1_cmapmarker default
		setstate flak88_2_cmapmarker default

		setstate rb_airplane invisible

		wait 150
		setautospawn        "The Forward Bunker"        0
		setautospawn        "Allied Garage"        1
		wait 350

		wm_number_of_objectives 5
		
		// Forward flag (P)
		wm_objective_status 1 1 0
		wm_objective_status 1 0 0
		// Main gate (P)
		wm_objective_status 2 1 0
		wm_objective_status 2 0 0
		// East Flak88 (P)
		wm_objective_status 3 1 0
		wm_objective_status 3 0 0
		// West Flak88 (P)
		wm_objective_status 4 1 0
		wm_objective_status 4 0 0
		// CP (S)
		wm_objective_status 5 1 0
		wm_objective_status 5 0 0

		wait 300

		setstate flak88_1 default
		setstate flak88_1_cmapmarker invisible
		setstate flak88_1_toi invisible
		setstate flak88_2 default
		setstate flak88_2_cmapmarker invisible
		setstate flak88_2_toi invisible
		setstate neutral_cp_toi invisible
	}

	trigger end_map
	{
		wait 500
		wm_announce "Both Flak88 guns have been destroyed!"
		wait 1000
		wm_setwinner 1
		wm_endround
		setstate rb_airplane default
		trigger rb_airdrop1 activate
	}
}

////////////////////////////////////////////////////////////////////////////////////////////////

forward_flag
{
	spawn
	{
		accum 0 set 0			// Spawn owner: 0-Axis, 1-Allied
		remove
	}


	trigger axis_capture
	{
		accum 0 abort_if_equal 0	//Abort if axis own

		accum 0 set 0
		setautospawn	"The Forward Bunker" 0
		setautospawn	"Allied Garage" 1

		wm_objective_status 1 1 0
		wm_objective_status 1 0 0

		wm_announce        "The Axis have reclaimed the forward bunker!"

		alertentity forward_wobj

		// *----------------------------------- vo ------------------------------------------*
		wm_addteamvoiceannounce 0 "radar_axis_bunker_stop"
		wm_addteamvoiceannounce 1 "radar_allies_bunker_capture"

		wm_teamvoiceannounce 0 "radar_axis_bunker_reclaimed"
		wm_teamvoiceannounce 1 "radar_allies_bunker_reclaimed"

		// *---------------------------------------------------------------------------------*
        }

        trigger allied_capture
	{
		accum 0 abort_if_equal 1
		accum 0 set 1

		setautospawn        "Axis Backspawn"        0
		setautospawn        "The Forward Bunker"        1

		wm_objective_status 1 1 1
		wm_objective_status 1 0 2

		wm_announce        "The Allies have captured the forward bunker!"

		alertentity forward_wobj

		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "radar_axis_bunker_captured"
		wm_teamvoiceannounce 1 "radar_allies_bunker_captured"

		wm_removeteamvoiceannounce 0 "radar_axis_bunker_stop"
		wm_removeteamvoiceannounce 1 "radar_allies_bunker_capture"

		// *---------------------------------------------------------------------------------*
	}

	trigger force_allied
	{
		accum 0 abort_if_equal 1	//Abort if allies own

		accum 0 set 1
		setautospawn	"Axis Backspawn" 0
		setautospawn	"The Forward Bunker" 1

		// *----------------------------------- vo ------------------------------------------*
		wm_removeteamvoiceannounce 0 "radar_axis_bunker_stop"
		wm_removeteamvoiceannounce 0 "radar_axis_entrance1_defend"

		wm_removeteamvoiceannounce 1 "radar_allies_bunker_capture"
		wm_removeteamvoiceannounce 1 "radar_allies_entrance1_destroy"
		wm_removeteamvoiceannounce 1 "radar_allies_entrances_destroy"
		// *---------------------------------------------------------------------------------*

		wm_objective_status 1 1 1
		wm_objective_status 1 0 2

		alertentity forward_wobj
	}

	trigger secure_flag 			// Hides the flag.....
	{
		setstate forward_flag invisible
	}
	trigger spawn_cp			// Forces allies to spawn at CP when built, NOT USED
	{
		setautospawn "the Command Post" 1
	}
	trigger turn_spawn			// Switches into 2nd set of spawnpoints
	{
		alertentity forward_spawn_2
		setstate forward_spawn_2 default
		setstate forward_spawn invisible
	}
}

main_gate
{
	spawn
	{
	wait 300
	remove
	setstate main_gate_info invisible
		trigger self open_teamdoors
	}

	death
	{

		wm_objective_status 2 1 1
		wm_objective_status 2 0 2

		trigger forward_flag force_allied
		trigger forward_flag secure_flag
		trigger forward_flag turn_spawn
		trigger main_gate open

		trigger self open_teamdoors
		trigger side_slidegate open

	}
	trigger open_teamdoors			// Opens the teamdoors at the forward spawn (after main gate)
	{
		setstate axis_teamdoor1 invisible
		setstate axis_teamdoor2 invisible
		setstate axis_teamdoor1_open default
		setstate axis_teamdoor2_open default
		trigger axis_teamdoor1_open open
		trigger axis_teamdoor2_open open
	}
}

///////// Forward spawn teamdoors /////////
///////////////////////////////////////////

axis_teamdoor1_open
{
	trigger open
	{
		playsound sound/movers/doors/door5_open.wav volume 255
		faceangles 0 90 0 1000
	}
}
axis_teamdoor2_open
{
	trigger open
	{
		playsound sound/movers/doors/door5_open.wav volume 255
		faceangles 0 -90 0 1000
	}
}



////////////////// Flak88 cannons - Main objective ///////////////////
// ===================================================================
flak88_1
{
	spawn
	{
		wait 300
		constructible_class 3
	}
	death
	{
		globalaccum 2 inc 1
		wm_announce "The East Flak88 has been destroyed!"

		wm_teamvoiceannounce 0 axis_hq_objective_destroyed
		wm_teamvoiceannounce 1 allies_hq_objective_destroyed

		wm_objective_status 4 1 1
		wm_objective_status 4 0 2

		trigger flak88_1_toi kill
		setstate flak88_1 invisible
		setstate flak88_1_d default
		setstate flak88_1_cmapmarker invisible
		globalaccum 2 trigger_if_equal 2 game_manager end_map
		remove
	}
}
flak88_1_toi
{
	trigger kill
	{
		remove
	}
}

flak88_2
{
	spawn
	{
		wait 300
		constructible_class 3
	}
	death
	{
		globalaccum 2 inc 1
		wm_announce "The West Flak88 has been destroyed!"

		wm_teamvoiceannounce 0 axis_hq_objective_destroyed
		wm_teamvoiceannounce 1 allies_hq_objective_destroyed

		wm_objective_status 5 1 1
		wm_objective_status 5 0 2

		trigger flak88_2_toi kill
		setstate flak88_2 invisible
		setstate flak88_2_d default
		setstate flak88_2_cmapmarker invisible
		globalaccum 2 trigger_if_equal 2 game_manager end_map
		remove
	}
}
flak88_2_toi
{
	trigger kill
	{
		remove
	}
}
	
	
////////////////// Command Post ///////////////////
// ================================================
neutral_cp_toi
{
	trigger show_neutral_cabinet			// Show Neutral Closed CP
	{
		setstate neutral_cp_closed default
		setstate neutral_cp_closed_model default
	}

	trigger hide_neutral_cabinet			// Hide Neutral Closed CP
	{
		setstate neutral_cp_closed invisible
		setstate neutral_cp_closed_model invisible
	}
}

// ================================================
allied_cp_open
{
	spawn
	{
		wait 100
		constructible_class 2			// Dyno+Satchel

		trigger self disable_cp_features		// Default charge bar times
	}
	trigger disable_cp_features
	{
		setstate allied_cp_open_model invisible	// Hide Open CP model

		setchargetimefactor 1 soldier 1
		setchargetimefactor 1 lieutenant 1
		setchargetimefactor 1 medic 1
		setchargetimefactor 1 engineer 1
		setchargetimefactor 1 covertops 1

		sethqstatus 1 0				// Landmines team warning message
		disablespeaker allied_cp_sound		// Disable morse code sound
	}

	trigger enable_cp_features
	{
		
		setstate allied_cp_open_model default	// Show open CP model

		setchargetimefactor 1 soldier 0.75
		setchargetimefactor 1 lieutenant 0.75
		setchargetimefactor 1 medic 0.75
		setchargetimefactor 1 engineer 0.75
		setchargetimefactor 1 covertops 0.75

		sethqstatus 1 1				// Landmines team warning message
		enablespeaker allied_cp_sound		// Enable morse code sound

	}

	buildstart final
	{
		trigger neutral_cp_toi hide_neutral_cabinet	// Hide Neutral CP model+clip brush
	}

	built final
	{
		//globalaccum 1 set 1
		setstate cp_wobj default
		alertentity cp_spawn
		trigger self enable_cp_features		// Increase charge bar times

		wm_announce "Allied Command Post constructed. Charge speed increased!"
		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "axis_hq_compost_constructed_allies"
		wm_teamvoiceannounce 1 "allies_hq_compost_constructed"
		wm_removeteamvoiceannounce 1 "allies_hq_compost_construct"
		// *----------------------------------- vo ------------------------------------------*
	}

	decayed final
	{
		setstate allied_cp_open_model invisible	// Hide Open CP model
		trigger neutral_cp_toi show_neutral_cabinet	// Show Neutral CP model+clip brush
	}

	death
	{
		//globalaccum 1 set 2
		setstate cp_wobj invisible
		alertentity cp_spawn
		trigger neutral_cp_toi show_neutral_cabinet	// Show Neutral CP model+clip brush
		trigger self disable_cp_features		// Default charge bar times

		wm_announce "Axis team has destroyed the Allied Command Post!"
		// *----------------------------------- vo ------------------------------------------*
		wm_addteamvoiceannounce 0 "axis_hq_compost_construct"
		wm_addteamvoiceannounce 1 "allies_hq_compost_construct"
		wm_teamvoiceannounce 0 "axis_hq_compost_construct"
		wm_teamvoiceannounce 1 "allies_hq_compost_damaged"
		// *----------------------------------- vo ------------------------------------------*
	}
}

// ================================================
axis_cp_open
{
	spawn
	{
		wait 100
		constructible_class 2			// Dyno+Satchel

		trigger self disable_cp_features		// Default charge bar times
	}

	trigger disable_cp_features
	{
		setstate axis_cp_open_model invisible	// Hide Open CP model

		setchargetimefactor 0 soldier 1
		setchargetimefactor 0 lieutenant 1
		setchargetimefactor 0 medic 1
		setchargetimefactor 0 engineer 1
		setchargetimefactor 0 covertops 1

		sethqstatus 0 0				// Landmines team warning message
		disablespeaker axis_cp_sound		// Disable morse code sound
	}

	trigger enable_cp_features
	{
		setstate axis_cp_open_model default	// Show open CP model

		setchargetimefactor 0 soldier 0.75
		setchargetimefactor 0 lieutenant 0.75
		setchargetimefactor 0 medic 0.75
		setchargetimefactor 0 engineer 0.75
		setchargetimefactor 0 covertops 0.75

		sethqstatus 0 1				// Landmines team warning message
		enablespeaker axis_cp_sound		// Enable morse code sound
	}

	buildstart final
	{
		trigger neutral_cp_toi hide_neutral_cabinet	// Hide Neutral CP model+clip brush
	}

	built final
	{
		//globalaccum 1 set 0
		trigger self enable_cp_features		// Increase charge bar times

		wm_announce "Axis Command Post constructed. Charge speed increased!"
		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "axis_hq_compost_constructed"
		wm_teamvoiceannounce 1 "allies_hq_compost_constructed_axis"
		wm_removeteamvoiceannounce 0 "axis_hq_compost_construct"
		// *----------------------------------- vo ------------------------------------------*
	}

	decayed final
	{
		setstate axis_cp_open_model invisible	// Hide Open CP model
		trigger neutral_cp_toi show_neutral_cabinet	// Show Neutral CP model+clip brush
	}

	death
	{
		//globalaccum 1 set 2
		trigger neutral_cp_toi show_neutral_cabinet	// Show Neutral CP model+clip brush
		trigger self disable_cp_features		// Default charge bar times

		wm_announce "Allied team has destroyed the Axis Command Post!"
		// *----------------------------------- vo ------------------------------------------*
		wm_addteamvoiceannounce 0 "axis_hq_compost_construct"
		wm_addteamvoiceannounce 1 "allies_hq_compost_construct"
		wm_teamvoiceannounce 0 "axis_hq_compost_damaged"
		wm_teamvoiceannounce 1 "allies_hq_compost_construct"
		// *----------------------------------- vo ------------------------------------------*
	}
}


/////////////////// Intermission chute & plane - by RayBan

rb_box_obj1	// this is the drop box
{
	spawn
	{
		wait 100
		setstate rb_box_obj1 invisible
	}

	trigger drop
	{
		trigger self start_sound
		gotomarker rb_landing1 200
	}

	trigger start_sound
	{
		stopsound
		playsound sound/world/flap.wav looping 256
	}

	trigger stop_sound
	{
		stopsound
	}
}

rb_chute1
{
	spawn
	{
		wait 50
		attachtotag rb_box_obj1 tag_chute
		startanimation 0 1 15
		setstate rb_chute1 invisible

	}
	
	trigger chute_control
	{
		startanimation 0 50 15 norandom noloop 	// chute deploys
		wait 1600
		startanimation 30 20 20 norandom noloop	// chute cycles in open animation (does nothing)

		wait 6650	// have to test how long the drop wait is before we collapse the chute
		startanimation 60 50 15 norandom noloop	// collapse chute ( frames 60-95 ) frames 95 to 120 are in full collapsed mode.
		wait 3250
		trigger rb_box_obj1 stop_sound
		remove rb_chute1
		//setstate rb_box_obj1 invisible
	}


}

rb_airdrop1
{
	spawn
	{
		wait 100
	}

	trigger activate
	{
		trigger rb_airplane1 start_fly
	}
	
	trigger drop_obj
	{
		setstate rb_box_obj1 default
		setstate rb_chute1 default
		trigger rb_box_obj1 drop
		trigger rb_chute1 chute_control
	}

}

rb_airplane1
{
	spawn
	{
		wait 400
		followspline 0 rb_plane1_setup 50000 length 32 wait
	}


	trigger start_fly
	{
		//trigger self start_sound	// if there was an airplane sound..
		followspline 0 rb_pspline_start 500 wait length 32
		trigger self drop_obj

	}

	trigger drop_obj
	{
		trigger rb_airdrop1 drop_obj
		followspline 0 rb_pspline_drop 500 wait length 32
		remove	// no need for a plane after this... so we get rid of it
	}
	
	trigger start_sound	// no sound, but if there was one, it can be used here.
	{				// just omit the sound stuff if not needed.
		stopsound
		//playsound sound/effects/plane_loop1.wav looping 512
	}

	trigger stop_sound
	{
		stopsound
	}
}